<?php
/**
 * echo Pinyin('谢景权','UTF-8');
 * 将       张建忠              =>       zhangjz@wxit.edu.cn
 * 将       肖颖                  =>       xiaoy@wxit.edu.cn
 * 然后存入数据库
 */
//exit("处理好");
include 'pinYin.php';
error_reporting(0);
set_time_limit(0);
$s = microtime(true);
$file_dir = "school.txt";

$i = 0;
$file = fopen ( $file_dir, "r" );
if(!$file){
	echo "文件打不开或不存在";
	exit;
}

/*从文件中每次读一行，将Email存入数据库*/
while ( !feof($file) ){
	$name = trim(fgets($file));
	if(empty($name))
		continue;
	
	$a = mb_substr($name, 0, 1, 'utf-8');
	$b = mb_substr($name, 1, 1, 'utf-8');
	$c = mb_substr($name, 2, 1, 'utf-8');
	
	$ok = null;
	$ok = Pinyin($a,'UTF-8');
	
	$b = Pinyin($b,'UTF-8');
	if(!empty($b))
		$ok .= substr($b, 0, 1);
	if(!empty($c)){
		$c = Pinyin($c,'UTF-8');
		$ok .= substr($c, 0, 1);
	}
	
	if(empty($ok))
		break;
	
	echo "{$ok}@wxit.edu.cn\r\n";
	/*
	if($name == "金华军")
		break;
	*/
}

fclose($file);
echo "用时:".number_format(microtime(true) - $s, 3, '.', '')."秒";